Skip to content

Compare APK versions with apk-tools tokenization - #45

Merged
andrew merged 1 commit into
mainfrom
apk-tools-comparator
Aug 29, 2026
Merged

Compare APK versions with apk-tools tokenization#45
andrew merged 1 commit into
mainfrom
apk-tools-comparator

Conversation

@andrew

@andrew andrew commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

The apk and alpine schemes previously delegated to the Gentoo comparator, which does not recognise the VCS suffixes (_cvs, _svn, _git, _hg), commit-hash markers (~<hex>), or apk-tools' leading-zero and uint64 numeric rules. That made 1.0_git compare equal to 1.0 and 1.0_cvs equal to 1.0_svn.

This ports the tokenizer from apk-tools src/version.c at 900a3f5280bfad7ea22eda7de46d0d4c0c9ce8f2 and vendors that revision's test/unit/version.data as a fixture. The test parses it directly and asserts all 738 comparison lines and 31 validity lines through CompareWithScheme and ValidWithScheme; the fuzzy-match section is skipped since vers does not model apk_version_match.

APK validation and prerelease classification now use the same tokenizer, so ValidWithScheme("0.1bc", "apk") is false and IsPrereleaseWithScheme("1.0_git20240101", "apk") is false while _alpha/_beta/_pre/_rc remain prerelease.

The vendored fixture is GPL-2.0-only test data, recorded in testdata/local/provenance.json alongside the existing dpkg and rpm fixtures under the same licence family.

The apk and alpine schemes previously delegated to the Gentoo
comparator, which does not recognise the VCS suffixes (_cvs, _svn,
_git, _hg), commit-hash markers (~<hex>), or apk-tools' leading-zero
and uint64 rules. Port the tokenizer from apk-tools src/version.c at
900a3f5 and drive it from the vendored test/unit/version.data fixture
(738 comparisons, 31 validity checks). APK validation and prerelease
classification now use the same tokenizer instead of Gentoo's.
@andrew
andrew merged commit c7ee1fd into main Aug 29, 2026
5 checks passed
@andrew
andrew deleted the apk-tools-comparator branch August 29, 2026 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant